/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 2 -*- */
/**
* @headerfile doubleengine.hpp
* 
* Header for easy managing the power of two engines.
* 
* @author Miguel Ángel Vílchez López 2010 <sacra@openmatica.es>
*
* Codigo is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* Codigo is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License along
* with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _MOKARDU_DOUBLEENGINE_HPP_
#define _MOKARDU_DOUBLEENGINE_HPP_

#include "softservo.hpp"

/**
* @class CMDoubleEngine
* @brief Managing a double motor vehicle.
*/

class CMDoubleEngine
{

	private:

		/**
		* Engine Left.
		*/
		CMSoftServo engine_left;
		
		/**
		* Engine Right.
		*/
		CMSoftServo engine_right;


	public:
	
		/**
		* Constructor.
		*
		* @param[in] acceleration The acceleration.
		* @param[in] min The minimum power.
		* @param[in] max The maximum power.
		*/
		CMDoubleEngine(int acceleration,int min,int max);
		
		/**
		* Destructor.
		*/
		~CMDoubleEngine();
		
		/**
		* Forward or backward moviment.
		*
		* @param[in] value The value of desired power.
		*/
		void go(int value);
		
		/**
		* Forward Left moviment, decreasing the power of left engine.
		*
		* @param[in] diff The difference of power for turning.
		*/				
		void goForwardLeft(int diff);
		
		/**
		* Forward Right moviment, decreasing the power of right engine.
		*
		* @param[in] diff The difference of power for turning.
		*/		
		void goForwardRight(int diff);
		
		/**
		* Backward Left moviment, decreasing the power of left engine.
		*
		* @param[in] diff The difference of power for turning.
		*/		
		void goBackwardLeft(int diff);
		
		/**
		* Backward Right moviment, decreasing the power of right engine.
		*
		* @param[in] diff The difference of power for turning.
		*/		
		void goBackwardRight(int diff);
		
		/**
		* Turn Left moviment.
		*
		* @param[in] diff The value of desired power.
		*/		
		void turnLeft(int diff);

		/**
		* Turn Right moviment.
		*
		* @param[in] diff The value of desired power.
		*/		
		void turnRight(int diff);

		/**
		* Motor emergency stop.
		*/
		void stop();
		
		/**
		* Accelerate the motor from now to end.
		*/
		void update();
		
		/**
		* Return the value of left engine.
		*
		* @return Returns 0 if succesfull, -1 if not.
		*/
		int getLeftEngine();
	
		/**
		* Return the value of right engine.
		*
		* @return Returns 0 if succesfull, -1 if not.
		*/
		int getRightEngine();

};
		
#endif // _MOKARDU_DOUBLEENGINE_HPP_
